package compiler.parse;
import java.io.*;

import compiler.errormsg.ErrorMsg;


public class TestParser {

  public compiler.errormsg.ErrorMsg errorMsg;
  public compiler.absyn.Exp absyn;

  public TestParser(String filename) {
	  try{
		    ErrorMsg errorMsg = new ErrorMsg(filename);
			InputStream inp = new FileInputStream(filename);
			Yylex lexer = new Yylex(inp, errorMsg);
			parser p = new parser(lexer,errorMsg);
			try {
				p.parse();
			} catch (Exception e) {
				e.printStackTrace();
			}
			filename="ma1.txt";
			PrintStream out=new PrintStream(filename);
			compiler.absyn.Print pr=new compiler.absyn.Print(out);
			pr.prExp(p.parseResult,0);
			compiler.absyn.IntExp e=new compiler.absyn.IntExp(0,0);
			compiler.absyn.Exp eq=(compiler.absyn.Exp)e;
			if(eq instanceof compiler.absyn.IntExp){System.out.println("true");}
			else{System.out.println("false");}
	  }catch(Exception e)
	       {e.printStackTrace();}
		
  }   
  public static void main(String[] argv){
	  TestParser test=new TestParser(argv[0]);
  }
}